package com.wzp.yyptproject.controller;


import com.wzp.yyptproject.entity.Doctor;
import com.wzp.yyptproject.entity.Doctor2;
import com.wzp.yyptproject.entity.EkBing;
import com.wzp.yyptproject.entity.User;
import com.wzp.yyptproject.repository.DoctorRepository;
import com.wzp.yyptproject.repository.EkBingRepository;
import com.wzp.yyptproject.service.DoctorService;
import com.wzp.yyptproject.service.EkBingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@CrossOrigin
@RequestMapping("doctor")
public class DoctorController {
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private DoctorRepository doctorRepository;
    @GetMapping("getdid")
    public Doctor findAllKeShi(Integer did){
        Doctor  doctor= doctorService.findAndByDDid(did);
            return doctor;

    }
    @GetMapping("getalldoctor")
    public List<Doctor> findAll(){
        List<Doctor>  doctorList= doctorService.findAll();
        return doctorList;

    }
    @GetMapping("findAlldoctor")
    public List<Doctor2> findAllDoctor(){

        List<Doctor> doctorList=doctorService.findAll();
        System.out.println("医生"+doctorList.toString());
        List<Doctor2> doctor2List = doctorService.DoctorMess(doctorList);
        return doctor2List;
    }
    @GetMapping("/findByPage")
    public Page<Doctor2> findByPage(@RequestParam(value = "pageCode" ,defaultValue = "0")int pageCode,
                                 @RequestParam(value = "pageSize" ,defaultValue = "4")int pageSize) {
        log.info("页码"+pageCode);
        log.info("页数"+pageSize);
        Page<Doctor2> doctor2Page= doctorService.findByPage(pageCode,pageSize);
        return doctor2Page;

//        return userService.findByPage(pageEntity.getPageCode(),pageEntity.getPageSize());
    }
    @GetMapping("findallcount")
    public Integer findAllCount(){
        return doctorService.findFuKeCount();

    }
}



